<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{L('member').L('register')}</title>
<link href="{CSS_PATH}font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="{CSS_PATH}bootstrap/css/bootstrap.min.css" media="all" />
<meta name="description" content="{L('member').L('register')}" />
<link href="{CSS_PATH}member-login.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{JS_PATH}Dialog/main.js"></script>
<script type="text/javascript" src="{CSS_PATH}bootstrap/js/bootstrap.min.js"></script>
<script src="{JS_PATH}cms.js" type="text/javascript"></script>
<script type="text/javascript" src="{CSS_PATH}default/plugin/layer/layer.js"></script>
<script type="text/javascript" src="{JS_PATH}register.js"></script>
<script type="text/javascript" src="{JS_PATH}formvalidator.js" charset="UTF-8"></script>
<script type="text/javascript" src="{JS_PATH}formvalidatorregex.js" charset="UTF-8"></script>
<script language="JavaScript">
<!--
$(function(){
	$.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}});
	$(":checkbox[name='agree']").formValidator({tipid:"protocoltip",onshow:"{L('read_protocol')}",onfocus:"{L('read_protocol')}"}).inputValidator({min:1,onerror:"{L('read_protocol')}"});
	{if $member_setting['mobile_checktype']=='2' && $sms_setting['sms_enable']=='1'}
	$("#mobile").formValidator({onshow:"请输入手机号码",onfocus:"请输入手机号码"}).inputValidator({min:1,max:11,onerror:"请输入正确的手机号码"});
	{/if}
	$("#mobile_verify").formValidator({onshow:"请输入手机收到的验证码",onfocus:"请输入手机收到的验证码"}).inputValidator({min:1,onerror:"请输入手机收到的验证码"}).ajaxValidator({
		type : "get",
		url : "api.php",
		data :"op=sms_idcheck&action=id_code",
		datatype : "html",
		{if $member_setting['mobile_checktype']=='2'}
		getdata:{mobile:"mobile"},
		{/if}
		async:"false",
		success : function(data){
			if( data == "1" ) {
				return true;
			} else {
				return false;
			}
		},
		buttons: $("#dosubmit"),
		onerror : "验证码错误",
		onwait : "请稍候..."
	});
	{$formValidator}
});
//-->
</script>
</head>
<body>
<div class="member-container register">
    <div class="title">{L('member').L('register')}</div>
    <div class="form">
        <form method="post" action="" id="myform" onsubmit="return checkall()">
        {dr_form_hidden()}
            <ul>
                <li><input type="text" class="input" name="username" id="username" placeholder="请输入{L('username')}" value=""></li>
                <li><input type="password" class="input" name="password" id="password" placeholder="请输入{L('password')}" value=""></li>
                <li><input type="password" class="input" name="pwdconfirm" id="pwdconfirm" placeholder="请输入{L('cofirmpwd')}" value=""></li>
                <li><input type="text" class="input" name="email" id="email" placeholder="请输入{L('email')}" value=""></li>
                <li><input type="text" class="input" name="nickname" id="nickname" placeholder="请输入{L('nickname')}" value=""></li>
                {if $member_setting['choosemodel']}
                {loop $forminfos $k $v}
                <li>{$v['form']}</li>
                {/loop}
                {/if}
                {if $sms_setting['sms_enable']=='1'}
                <li><input type="text" class="input code" name="code" id="code" placeholder="请输入{L('checkcode')}">{form::checkcode('code_img', '5', '20', 126, 40)}</li>

                <div class="input"><label> 手机号码：</label><div class="form"><div id="mobile_div"><input type="text" name="mobile" id="mobile" value="" size="15" class="input-text" title="此服务免费,验证码将以短信免费发送到您的手机"> 
                    <div class="submit"><button onclick="get_verify()" type="button" class="hqyz">获取短信验证码</button></div> <span id="mobileTip"></span>
                    <br>
                    </div>
                    <div id="mobile_send_div" style="display:none">此服务免费,验证码已发送到<span id="mobile_send"></span>，<span id="edit_mobile" style="display:none"><a href="javascript:void();" onclick="edit_mobile()">修改号码</a>，</span> 如果超过120秒未收到验证码，您可以免费重新获取。<br><br>
                    <div class="submit"><button type="button" id="GetVerify" onclick="get_verify()" class="hqyz">重获短信验证码</button></div> <br><br></div> 
                    <script language="JavaScript">
                    <!--
                        var times = 120;
                        var isinerval;
                        function get_verify() {
                            var session_code = $('#code').val();
                            if(session_code=='') {
                                dr_tips(0, '请输入验证码');
                                $('#code').focus();
                                return false;
                            }
                            var mobile = $("#mobile").val();
                            var partten = /^[0-9]+.?[0-9]*/;
                            if(!partten.test(mobile) || mobile.length != 11){
                                dr_tips(0, "请输入正确的手机号码");
                                $('#mobile').focus();
                                return false;
                            }
                            $.ajax({
                                type: "get",   
                                url: "?m=member&c=index&a=public_checkmobile_ajax",   
                                dataType: "html",
                                async: false,
                                data: "mobile="+mobile,
                                success: function(msg){  
                                if(msg == '1'){
                                    $.ajax({
                                        type: "POST",
                                        dataType: "json",
                                        url: "api.php?op=sms",
                                        data: {mobile: mobile,session_code:session_code,{SYS_TOKEN_NAME}:'{csrf_hash()}',random:Math.random()},
                                        success: function(json) {
                                            if (json.code) {
                                                $("#mobile_send").html(mobile);
                                                $("#mobile_div").css("display","none");
                                                $("#mobile_send_div").css("display","");
                                                times = 120;
                                                $("#GetVerify").attr("disabled", true);
                                                isinerval = setInterval("CountDown()", 1000);
                                            } else {
                                                dr_tips(json.code, json.msg);
                                            }
                                        }
                                    });
                                }else if(msg == '-1'){
                                    layer.msg('手机号码已存在', {icon:2,time: 1000});
                                }else if(msg == '0'){
                                    layer.msg('手机号码格式不正确', {icon:2,time: 1000});
                                }
                                }
                            });
                        }
                        function CountDown() {
                            if (times < 1) {
                                $("#GetVerify").html("获取短信验证码").attr("disabled", false);
                                $("#edit_mobile").css("display","");
                                clearInterval(isinerval);
                                return;
                            }
                            $("#GetVerify").html(times+"秒后重获验证码");
                            times--;
                        }
                        function edit_mobile() {
                            $("#mobile_div").css("display","");
                            $("#mobile_send_div").css("display","none");
                        }
                    //-->
                    </script>
                    </div></div>
                    <div class="input"><label>短信校验码：</label><input type="text" name="mobile_verify" id="mobile_verify" value="" size="14" class="input-text"></div>    
                {/if}
                {if $member_setting['register']['code'] && $sms_setting['sms_enable']!='1'}
                <li><input type="text" class="input code" name="code" id="code" placeholder="请输入{L('checkcode')}">{form::checkcode('code_img', '5', '20', 126, 40)}</li>
                {/if}
                <li><input type="submit" class="submit" name="dosubmit" id="dosubmit" value="{L('agree_protocol_post')}"></li>
                <li class="last_li"><input type="checkbox" checked="checked" value="1" id="agree" name="agree"/> <a onclick="show_protocol()" href="javascript:void(0);">{L('click_read_protocol')}</a></li>
            </ul>
            <div class="bottom">{L('already_have_account')}<a href="{APP_PATH}index.php?m=member&c=index&a=login">{L('login')}</a>&nbsp;&nbsp;&nbsp; <a href="index.php?m=member&c=index&a=public_get_password_type&siteid={$siteid}" target="_blank" style="color:#959595;float: right">{L('forgetpassword')}</a></div>
        </form>
    </div>
</div>
<div class="clearfix"></div>
<div class="footer">
    <div class="container">
        <p>Powered by <strong><a href="http://www.kaixin100.cn" target="_blank">Kaixin100</a></strong> <em>{get_pc_version(1)}</em> &copy; 2006-{date('Y', SYS_TIME)} <img src="{IMG_PATH}copyright.gif"/></p>
    </div>
</div>
<script type="text/javascript">
function checkname(){
    var res = false;
    if($("#username").val() != ''){
        $.ajax({
            type: "get",
            url: "?m=member&c=index&a=public_checkname_ajax",
            dataType: "html",
            async: false,
            data: "username="+$('#username').val(),
            beforeSend: function(){
                $("#dosubmit").attr({disabled: "disabled" });
            },
            success: function(msg){
            if(msg == '1'){
                $("#dosubmit").removeAttr("disabled");
                res = true;
            }else if(msg == '-1'){
                layer.msg('{L('username')}已存在', {icon:2,time: 1000});
            }else if(msg == '0'){
                layer.msg('{L('username')}格式不正确', {icon:2,time: 1000});
            }
            }
        });
        return res;
    }else{
        layer.msg('{L('username')}不能为空', {icon:2,time: 1000});
        return res;
    }
}
function checknickname(){
    var res = false;
    if($("#nickname").val() != ''){
        $.ajax({
            type: "get",
            url: "?m=member&c=index&a=public_checknickname_ajax",
            dataType: "html",
            async: false,
            data: "nickname="+$('#nickname').val(), 
            beforeSend: function(){
                $("#dosubmit").attr({disabled: "disabled" });
            },
            success: function(msg){
            if(msg == '1'){
                $("#dosubmit").removeAttr("disabled");
                res = true;
            }else if(msg == '-1'){
                layer.msg('{L('nickname')}已存在', {icon:2,time: 1000});
            }else if(msg == '0'){
                layer.msg('{L('nickname')}格式不正确', {icon:2,time: 1000});
            }
            }
        });
        return res;
    }else{
        layer.msg('{L('nickname')}不能为空', {icon:2,time: 1000});
        return res;
    }
}
function checkemail(){
     var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/; 
     var res = false;
     if(reg.test($("#email").val())){
        $.ajax({
            type: "get",
            url: "?m=member&c=index&a=public_checkemail_ajax",
            dataType: "html",
            async: false,    
            data: "email="+$('#email').val(), 
            beforeSend: function(){
                $("#dosubmit").attr({disabled: "disabled" });
            },
            success: function(msg){  
                if(msg == '1'){
                    $("#dosubmit").removeAttr("disabled");
                    res = true;
                }else if(msg == '-1'){
                    layer.msg('{L('email')}已存在', {icon:2,time: 1000});
                }else if(msg == '0'){
                    layer.msg('{L('email')}格式不正确', {icon:2,time: 1000});  
                }
            }
        });
        return res;
    }else{
        layer.msg('{L('email')}格式不正确', {icon:2,time: 1000});
        return res;
    }
}
{if !isset($_GET['modelid']) && !isset($_GET['t']) && !empty($member_setting['showregprotocol'])}
show_protocol();
{/if}
function show_protocol(){
   layer.open({
      type: 2,
      title: '会员注册协议',
      skin: 'layui-layer-rim', 
      area: ['550px', '320px'], 
      content: '?m=member&c=index&a=register&protocol=1'
    });
}
</script>
</body>
</html>